Skip to content

Use the stdlib Map for the compiler's maps - #8790

Merged
cknitt merged 2 commits into
stdlib-setfrom
stdlib-map
Oct 11, 2026
Merged

cknitt merged 2 commits into
stdlib-setfrom
stdlib-map

Conversation

@cknitt

@cknitt cknitt commented Oct 10, 2026

Copy link
Copy Markdown
Member

Last of four PRs moving the compiler's own collections onto the OCaml standard library, stacked on #8789. This one covers maps.

Map_ident, Map_int and Map_string are now Map.Make instances with the same comparison functions, including Ext_string.compare (length first) for strings, so iteration order is unchanged. Call sites use the stdlib API and argument order. The ext-only helpers map onto stdlib functions:

  • find_exn → find
  • find_default → find_opt with a default
  • adjust → update
  • disjoint_merge_exn → union with a failing merge
  • to_sorted_array_with_f → bindings
  • compare_key → Ext_string.compare

Ext_map and Map_gen are removed, together with the ounit tests of their helpers. With this PR the compiler has no hand-written ordered or hashed collections left apart from Ordered_hash_map and Hash_set_ident_mask, which have no stdlib equivalent.

Output: byte-identical to #8789 on 628 files (Belt, all of tests/tests/src, and the benchmark stress inputs).

Performance: the whole stack against master measures CPU +0.2% (noise) and allocation +0.6%. The removed maps had a compact leaf node that stdlib Map doesn't have.

🤖 Generated with Claude Code

@cknitt
cknitt added this pull request to stack #8788 October 10, 2026 19:01
@pkg-pr-new

pkg-pr-new Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@8790

@rescript/belt

npm i https://pkg.pr.new/@rescript/belt@8790

@rescript/darwin-arm64

npm i https://pkg.pr.new/@rescript/darwin-arm64@8790

@rescript/darwin-x64

npm i https://pkg.pr.new/@rescript/darwin-x64@8790

@rescript/linux-arm64

npm i https://pkg.pr.new/@rescript/linux-arm64@8790

@rescript/linux-x64

npm i https://pkg.pr.new/@rescript/linux-x64@8790

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@8790

@rescript/win32-x64

npm i https://pkg.pr.new/@rescript/win32-x64@8790

commit: 4c2e760

@cknitt
cknitt marked this pull request as ready for review October 11, 2026 05:37
@cknitt

cknitt commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

@codex review

cknitt and others added 2 commits October 11, 2026 07:38
Map_ident, Map_int and Map_string are Map.Make instances with the same
comparisons; Ext_map and Map_gen are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T05:40:37.711586Z 4d1e83e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 4d1e83e935

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cknitt
cknitt requested a review from cristianoc October 11, 2026 05:48
@codecov

codecov Bot commented Oct 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.91837% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.57%. Comparing base (1c97f29) to head (4c2e760).

Files with missing lines Patch % Lines
compiler/core/lam_compile.ml 85.71% 1 Missing ⚠️
compiler/core/lam_compile_main.ml 83.33% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##           stdlib-set    #8790      +/-   ##
==============================================
- Coverage       80.58%   80.57%   -0.01%     
==============================================
  Files             455      452       -3     
  Lines           62231    61966     -265     
==============================================
- Hits            50147    49928     -219     
+ Misses          12084    12038      -46     
Files with missing lines Coverage Δ
compiler/core/js_cmj_format.ml 94.44% <100.00%> (+0.10%) ⬆️
compiler/core/js_pass_tailcall_inline.ml 80.39% <100.00%> (+1.22%) ⬆️
compiler/core/lam_beta_reduce.ml 84.31% <100.00%> (ø)
compiler/core/lam_closure.ml 72.15% <100.00%> (+0.72%) ⬆️
compiler/core/lam_coercion.ml 97.50% <100.00%> (ø)
compiler/core/lam_compile_context.ml 93.75% <100.00%> (ø)
compiler/core/lam_pass_count.ml 93.97% <100.00%> (ø)
compiler/core/lam_pass_deep_flatten.ml 88.75% <100.00%> (ø)
compiler/core/lam_stats_export.ml 91.11% <ø> (ø)
compiler/ext/ext_pp_scope.ml 100.00% <100.00%> (ø)
... and 7 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cknitt
cknitt merged commit 126229a into master Oct 11, 2026
24 checks passed
@cknitt
cknitt deleted the stdlib-map branch October 11, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants